package com.hub.utils.enums;

import com.hub.utils.KeyValueModel;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author hub
 * @version 1.0
 * @date 2020/5/15 15:28
 * @description:
 */
@Getter
public enum BrandGradeEnum {

    Internal(1,"国内品牌"),
    International(2,"国际品牌");

    private int code;
    private String description;

    BrandGradeEnum(int code, String desc) {
        this.code = code;
        this.description = desc;
    }

    /**
     * 获取枚举值的描述
     * @param index
     * @return
     */
    public static String getDescription(int index) {
        for(BrandGradeEnum uge : BrandGradeEnum.values()){
            if(uge.getCode() == index){
                return uge.description;
            }
        }
        return "未知编码";
    }

    /**
     * 获取枚举Code-Description
     * @return
     */
    public static List<KeyValueModel> getMaps()
    {
        List<KeyValueModel> list = new ArrayList();
        for(BrandGradeEnum uge : BrandGradeEnum.values()){
            KeyValueModel kv = new KeyValueModel();
            kv.setKey(uge.getCode());
            kv.setValue(uge.description);
            list.add(kv);
        }

        return list;
    }
}
